<template>
  <div class="labSubItem">
    <Table border :columns="columns" :data="row" size="small"></Table>
  </div>
</template>

<script>
  export default {
    name: "labSubItem",
    props: {
      row: Array,
      isEdit: Boolean
    },
    data() {
      return {
        columns: [
          {
            title: '序号',
            key: 'no'
          },
          {
            title: '代码',
            key: 'code'
          },
          {
            title: '名称',
            key: 'display'
          },
          {
            title: '结果',
            key: 'value',
            render: (h, params) => {
              if (this.isEdit) {
                return h('Input', {
                  props: {
                    value: params.row.value
                  },
                  on: {
                    'input': (value) => {
                      // this.$emit('input', value);
                      this.row[params.index][params.column.key] = value
                    }
                  }
                })
              } else {
                return h('span', params.row.value)
              }
            }
          },
          {
            title: '单位',
            key: 'unit'
          },
          {
            title: '参考范围',
            key: 'low',
            render: (h, params) => {
              return h('span', params.row.low + ' - ' + params.row.high)
            }
          }
        ]
      }
    }
  }
</script>

<style scoped>

</style>
